import argparse
import shutil
import os
import random


def get_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('src', type=str, help='src image dir.', nargs=1)
    parser.add_argument('dst', type=str, help='dest image dir.', nargs=1)
    parser.add_argument('--seed', type=int, help='random seed.', default=0)
    parser.add_argument(
        '--num', type=int, help='num of files desired.', default=20)
    args = parser.parse_args()
    return args


if __name__ == '__main__':
    args = get_args()
    src_dir = args.src[0]
    dst_dir = args.dst[0]
    seed = args.seed
    src_files = []
    for f in os.listdir(src_dir):
        full_path = os.path.join(src_dir, f)
        if os.path.isfile(full_path):
            src_files.append(full_path)

    random.seed(seed)
    selected_imgs = random.sample(src_files, k=args.num)
    for f in selected_imgs:
        shutil.copy(f, dst_dir)
